# File: Items.py
# Copyright 2010 
# Author: Andrew Dorrycott
# License: GNU Lesser General Public License
# Original Repository: http://code.google.com/p/bobthezombie/

import sys
import pygame
import random
import datetime
import math

from Standard import *

class Item(WorldObject):
    def __init__(self, x, y, engine, view_image = IMAGES_BOB['CollisionMask'], collision_image = IMAGES_BOB['CollisionMask'], scale = 1.0):
        WorldObject.__init__(self, x, y, engine, view_image, collision_image, scale)
        
        # Used for sprite.collide_circle
        self.radius = 30
    
    def HandleBeingPickedUp(self, bob):
        # Create the event "picked_up_item" with variables, current_x and current_y
        self.engine.SendEvent(CustomEvents.picked_up_item, current_x = self.current_x, current_y = self.current_y, found_text = "Found %s" % self.__class__.__name__)# Children should handle this

# Useful Items
class Syringe(Item):
    def __init__(self, x, y, engine, view_image = IMAGES_SYRINGE[4], collision_image = IMAGES_SYRINGE[4], scale = 1.5):
        Item.__init__(self, x, y, engine, view_image, collision_image, scale)
        
        # How much of the cure has bob found
        self.cure_amount = 10
    
    def HandleBeingPickedUp(self, bob):
        # Call Super Class to create event
        Item.HandleBeingPickedUp(self, bob)
        
        bob.UpdateCure(self.cure_amount)

class Meat(Item):
    def __init__(self, x, y, engine, view_image = IMAGES_MEAT[1], collision_image = IMAGES_MEAT[1], scale = 1.5):
        Item.__init__(self, x, y, engine, view_image, collision_image, scale)
        
        # How much to heal
        self.health_amount = 20
        self.sanity_amount = 10
    
    def HandleBeingPickedUp(self, bob):
        # Call Super Class to create event
        Item.HandleBeingPickedUp(self, bob)
        
        bob.UpdateHealth(self.health_amount)
        bob.UpdateSanity(self.sanity_amount)

class ResearchDocument(Item):
    def __init__(self, x, y, engine, view_image = IMAGES_DOCUMENT, collision_image = IMAGES_DOCUMENT, scale = 1.5):
        Item.__init__(self, x, y, engine, view_image, collision_image, scale)
        
        # How much DNA to give Bob
        self.dna_amount = 2
    
    def HandleBeingPickedUp(self, bob):
        # Call Super Class to create event
        Item.HandleBeingPickedUp(self, bob)
        
        bob.UpdateDNA(self.dna_amount)

class DNA(Item):
    def __init__(self, x, y, engine, view_image = IMAGES_DNA, collision_image = IMAGES_DNA, scale = 1.5):
        Item.__init__(self, x, y, engine, view_image, collision_image, scale)
        
        # How much DNA to give Bob
        self.dna_amount = 1
    
    def HandleBeingPickedUp(self, bob):
        # Call Super Class to create event
        Item.HandleBeingPickedUp(self, bob)
        
        bob.UpdateDNA(self.dna_amount)

class DisguiseLabCoat(Item):
    def __init__(self, x, y, engine, view_image = IMAGES_DISGUISES[3], collision_image = IMAGES_DISGUISES[3], scale = 1.0):
        Item.__init__(self, x, y, engine, view_image, collision_image, scale)
        
        # How much DNA to give Bob
        self.cover = 90 # 90% chance of the NPCs not detecting you while under cover
    
    def HandleBeingPickedUp(self, bob):
        # Call Super Class to create event
        Item.HandleBeingPickedUp(self, bob)
        
        bob.UpdateDisguise('LabCoat', self.cover)

# Ammo items
class ShotgunAmmo(Item):
    def __init__(self, x, y, engine, view_image = IMAGES_SHOTGUN_AMMO, collision_image = IMAGES_SHOTGUN_AMMO, scale = 1.0, ammo_count = 8):
        Item.__init__(self, x, y, engine, view_image, collision_image, scale)
        
        # How much ammo to give Bob
        self.ammo_amount = ammo_count
    
    def HandleBeingPickedUp(self, bob):
        # Call Super Class to create event
        Item.HandleBeingPickedUp(self, bob)
        
        bob.UpdateAmmo('Shotgun', self.ammo_amount)

class RifleAmmo(Item):
    def __init__(self, x, y, engine, view_image = IMAGES_RIFLE_AMMO, collision_image = IMAGES_RIFLE_AMMO, scale = 1.0, ammo_count = 15):
        Item.__init__(self, x, y, engine, view_image, collision_image, scale)
        
        # How much ammo to give Bob
        self.ammo_amount = ammo_count
    
    def HandleBeingPickedUp(self, bob):
        # Call Super Class to create event
        Item.HandleBeingPickedUp(self, bob)
        
        bob.UpdateAmmo('Rifle', self.ammo_amount)

class PistolAmmo(Item):
    def __init__(self, x, y, engine, view_image = IMAGES_PISTOL_AMMO, collision_image = IMAGES_PISTOL_AMMO, scale = 1.0, ammo_count = 7):
        Item.__init__(self, x, y, engine, view_image, collision_image, scale)
        
        # How much ammo to give Bob
        self.ammo_amount = ammo_count
    
    def HandleBeingPickedUp(self, bob):
        # Call Super Class to create event
        Item.HandleBeingPickedUp(self, bob)
        
        bob.UpdateAmmo('Pistol', self.ammo_amount)

# Weapons
class Shotgun(Item):
    def __init__(self, x, y, engine, view_image = IMAGES_SHOTGUN, collision_image = IMAGES_SHOTGUN, scale = 2.0, ammo_count = 8):
        Item.__init__(self, x, y, engine, view_image, collision_image, scale)
        
        # How much ammo to give the gun
        self.ammo_amount = ammo_count
    
    def HandleBeingPickedUp(self, bob):
        # Call Super Class to create event
        Item.HandleBeingPickedUp(self, bob)
        
        bob.AddWeapon('Shotgun')
        bob.UpdateAmmo('Shotgun', self.ammo_amount)

class Rifle(Item):
    def __init__(self, x, y, engine, view_image = IMAGES_RIFLE, collision_image = IMAGES_RIFLE, scale = 2.0, ammo_count = 15):
        Item.__init__(self, x, y, engine, view_image, collision_image, scale)
        
        # How much ammo to give the gun
        self.ammo_amount = ammo_count
    
    def HandleBeingPickedUp(self, bob):
        # Call Super Class to create event
        Item.HandleBeingPickedUp(self, bob)
        
        bob.AddWeapon('Rifle')
        bob.UpdateAmmo('Rifle', self.ammo_amount)

class Pistol(Item):
    def __init__(self, x, y, engine, view_image = IMAGES_PISTOL, collision_image = IMAGES_PISTOL, scale = 2.0, ammo_count = 7):
        Item.__init__(self, x, y, engine, view_image, collision_image, scale)
        
        # How much ammo to give the gun
        self.ammo_amount = ammo_count
    
    def HandleBeingPickedUp(self, bob):
        # Call Super Class to create event
        Item.HandleBeingPickedUp(self, bob)
        
        bob.AddWeapon('Pistol')
        bob.UpdateAmmo('Pistol', self.ammo_amount)
